package com.netty.pro.netty.inbound_outbound;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * @author xuzn
 * @ClassName: Inoutserver
 * @ProjectName netty-pro
 * @date 2020/3/20/7:53
 */
public class Inoutserver {
  public static void main(String[] args) throws Exception {
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    ServerBootstrap bootstrap = new ServerBootstrap();
    try {
      bootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
              .childHandler(new MyServerChannelHandlerInitializer());
      ChannelFuture channelFuture = bootstrap.bind(7000).sync();
      channelFuture.channel().closeFuture().sync();
    } finally {
      bossGroup.shutdownGracefully();
      workerGroup.shutdownGracefully();
    }
  }
}
